import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');

@Define.Table({ TableName: 'modifieroption' })
export class ModifierOption extends EntityObjectType<ModifierOption> {
    @Define.PrimaryKey()
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    name: string;

    @Define.Column({
        DataType: Define.DataType.Decimal,
        DataLength: 10,
        DecimalPoint: 3,
        NotAllowNULL: true,
        DefaultValue: 0,
    })
    price: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
    })
    priceRole?: ModifierOptionPriceRole;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    modifierId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    storeId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    productId: string;

    @Define.Column({
        DataType: Define.DataType.BOOL
    })
    isDefault: boolean;

    @Define.Column({
        DataType: Define.DataType.INT
    })
    index: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    createTime: number;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;
}

export enum ModifierOptionPriceRole {
    EachItem = 'eachItem',
    EachOrder = 'eachOrder'
}